#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 20,mod = 998244353;
inline int qpow(int x,int y)
{
	int res = 1;
	while(y)
	{
		if(y&1) res = res*x%mod;
		y>>=1;
		x = x*x%mod; 
	}
	return res;
}
int n,m,a[N],b[N],c[N];
struct node{
	int a[N][N]; 
	inline void init(int x = 0)
	{
		for(int i = 1;i<=n;i++)
			for(int j = 1;j<=n;j++)
				a[i][j] = x;
	}
	inline friend node operator * (node x,node y)
	{
		node res;res.init();
		for(int i = 1;i<=n;i++)
			for(int k = 1;k<=n;k++)
				for(int j = 1;j<=n;j++)
					(res.a[i][j]+=x.a[i][k]*y.a[k][j])%=mod;
		return res;
	}
}pw[64];
int tmp[N];
void mul(node &x,node &y)
{
	for(int i = 1;i<=n;i++) tmp[i] = x.a[1][i],x.a[1][i] = 0;
	for(int k = 1;k<=n;k++)
		for(int j = k;j<=n;j++)
			(x.a[1][j]+=tmp[k]*y.a[k][j])%=mod;
}
signed main()
{
	freopen("yt.in","r",stdin);
	freopen("yt.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i = 1;i<=n;i++) cin>>a[i]>>b[i],c[i] = qpow(a[i],b[i]+1);
	for(int i = 1;i<=n;i++)
		for(int j = i;j<=n;j++)
			pw[0].a[i][j] = a[j];
	for(int i = 1;i<=60;i++)
		pw[i] = pw[i-1]*pw[i-1];
	int ans = 0;
	for(int z = 0;z<(1<<n);z++)
	{
		int sum = 0,now = 1;
		for(int i = 1;i<=n;i++)
			if((z>>i-1)&1) sum+=b[i]+1,now = now*c[i]%mod;
		sum = m-sum;
		if(sum<0) continue;
		node tmp;tmp.init();
		tmp.a[1][1] = 1;
		for(int i = 60;~i;i--)
			if((sum>>i)&1) mul(tmp,pw[i]);
		int s = 0;
		for(int i = 1;i<=n;i++) (s+=tmp.a[1][i])%=mod;
		s = s*now%mod;
//		cout<<z<<":"<<s<<'\n';
		if(__builtin_popcount(z)&1) (ans+=mod-s)%=mod;
		else (ans+=s)%=mod;
	}
	cout<<ans;
	return 0;
}

